package com.toprand.lockscreenservice;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import android.util.Log;

import com.toprand.lockscreenvideo.OnScreenLockedListener;
import com.toprand.lockscreenvideo.ServiceManager;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setShowWhenLocked(true);
        setContentView(R.layout.activity_main);
    }

    @Override
    protected void onResume() {
        super.onResume();
        if (PermissionUtil.checkPermission(this, PermissionUtil.permissions)) {
            ServiceManager.startLockScreenService(this, new OnScreenLockedListener() {
                @Override
                public void onLocked(Context context) {
                    Log.e("Wakelock", "VideoActivity.start()");
                    Intent intent = new Intent(context, VideoActivity.class);
                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    context.startActivity(intent);
                }
            });
        }
    }
}